#include "cv_match/base.hpp"

Camera::Camera()
{
	//std::cout << "Camera构造函数" << std::endl;
}

Camera::~Camera()
{
	//std::cout << "Camera析构函数" << std::endl;
}

int Camera::read_yaml_file(const std::string& filename)
{
	cv::FileStorage fs_read(filename, cv::FileStorage::READ);

	fs_read["model"] >> model_;
	fs_read["imageSize"] >> image_size;

	fs_read["cameraMatrix"] >> camera_matrix;
	fs_read["distCoeffs"] >> distort_coefficient;

	fs_read.release();

	std::cout << "model: " << model_ << std::endl;
	std::cout << "cameraMatrix: " << camera_matrix << std::endl;
	std::cout << "distCoeffs: " << distort_coefficient << std::endl;

	return 1;
}

PinholeCamera::PinholeCamera() :Camera()
{
	//std::cout << "PinholeCamera构造函数" << std::endl;
}


PinholeCamera::~PinholeCamera()
{
	//std::cout << "PinholeCamera析构函数" << std::endl;
}

float PinholeCamera::fx()
{
	assert(!camera_matrix.empty());
	return camera_matrix.at<float>(0, 0);
}

float PinholeCamera::cx()
{
	assert(!camera_matrix.empty());
	// 0表示行号，2表示列号，如果用x和y来取值，则这样写"at<float>(y, x)"
	return camera_matrix.at<float>(0, 2);
}